f(char*a,char*b){return strcmp(a,b);}
char s[16<<21][11],now[11];
n,a,t;
k_most_substr(int N,int K,char*inp)
{
	--K;
	for(n=0;n<N-K;n++)
		strncpy(s[n],inp+n,K+1),s[n][K+1]=0,puts(s[n]);
	qsort(*s,N-K,K+1,f);
puts("qsort");
	for(t=a=n=0,strcpy(now,*s);n<N-K;n++)
		if(strcmp(now,s[n]))a=a>n-t?a:n-t,t=n,strcpy(now,s[n]),puts(now);
	
	return a;
}

main(N,K){static char inp[16<<21];scanf("%d%d",&N,&K);scanf("%s",inp);printf("%d\n",k_most_substr(N,K,inp));}
